package models

import (
	"github.com/astaxie/beego/orm"
	"fmt"
)

type PayItem struct {
	Id       int    `orm:"column(id);auto"`
	Type     int8   `orm:"column(type)" description:"计费类型"`
	Code     string `orm:"column(code);size(20)" description:"代码"`
	Name     string `orm:"column(name);size(20)" description:"名称"`
	Desc     string `orm:"column(desc);size(40);null" description:"描述"`
	Price    int    `orm:"column(price)" description:"单价"`
	Coin     int    `orm:"column(coin)" description:"书币"`
	Gift     int    `orm:"column(gift)" description:"书券"`
	Extra    int    `orm:"column(extra)" description:"书币[赠送]"`
	Discount int8   `orm:"column(discount)" description:"折扣"`
	ExtraDay int16  `orm:"column(extra_day)" description:"赠送天数"`
	LimitDay int16  `orm:"column(limit_day)" description:"限购天数"`
	SortId   int    `orm:"column(sort_id)" description:"排序ID"`
	IsHot    int8   `orm:"column(is_hot)" description:"是否推荐"`
	IsOnce   int8   `orm:"column(is_once)" description:"是否限购1次"`
	IsDouble int8   `orm:"column(is_double)" description:"是否1送1"`
	IsDelete int8   `orm:"column(is_delete)" description:"是否删除"`
}

func (t *PayItem) TableName() string {
	return "pay_item"
}

func init() {
	orm.RegisterModel(new(PayItem))
}

func GetAllPayItem ()([]*PayItem,error){
	payItems := make([]*PayItem,0)
	_,err := orm.NewOrm().QueryTable("pay_item").All(&payItems)
	if err != nil {
		fmt.Println("select pay_item error",err)
		return nil,err
	}
	return payItems,nil
}



